<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1. 正整数和负整数的最大计数
        // 如何找到所有正整数 => 找到大于0的数 => 二分查找 >= 0
        // 如果找到所有负整数 => 找到小于0的数
        var maximumCount = function(nums) {
            let upNum = 0;
            let downNum = 0;
            for (i = 0; i < nums.length; i++) {
                if (nums[i] > 0) {
                    upNum++
                } else if (nums[i] <0) {
                    downNum++
                }
            }
            return Math.max(upNum, downNum)
        };
        console.log(maximumCount([-2,-1,-1,1,2,3]), 'maximumCount');
        console.log(maximumCount([-3,-2,-1,0,0,1,2]), 'maximumCount');
        console.log(maximumCount([5,20,66,1314]), 'maximumCount');
        
    </script>
</body>

</html>